<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>test_can_create_person_and_album_and_song (TestTunecoreDirect)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File test/test_tunecore_direct.rb, line 26</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">test_can_create_person_and_album_and_song</span>
    <span class="ruby-comment cmt"># create the person</span>
    <span class="ruby-identifier">person</span> = <span class="ruby-constant">TunecoreDirect</span><span class="ruby-operator">::</span><span class="ruby-constant">Person</span>.<span class="ruby-identifier">new</span>
    <span class="ruby-identifier">person</span>.<span class="ruby-identifier">name</span> = <span class="ruby-value str">&quot;Joe Schmoe&quot;</span>
    <span class="ruby-identifier">person</span>.<span class="ruby-identifier">email</span> = <span class="ruby-ivar">@email</span>
    <span class="ruby-identifier">person</span>.<span class="ruby-identifier">password</span> = <span class="ruby-value str">&quot;my_pas$word&quot;</span>
    <span class="ruby-identifier">person</span>.<span class="ruby-identifier">phone_number</span> = <span class="ruby-value str">&quot;212-555-1212&quot;</span>
    <span class="ruby-identifier">person</span>.<span class="ruby-identifier">country</span> = <span class="ruby-value str">&quot;United States&quot;</span>
    <span class="ruby-identifier">person</span>.<span class="ruby-identifier">postal_code</span> = <span class="ruby-value str">&quot;11201&quot;</span>
    <span class="ruby-identifier">assert</span> <span class="ruby-identifier">person</span>.<span class="ruby-identifier">create</span>
    
    <span class="ruby-comment cmt"># create the album</span>
    <span class="ruby-identifier">album</span> = <span class="ruby-constant">TunecoreDirect</span><span class="ruby-operator">::</span><span class="ruby-constant">Album</span>.<span class="ruby-identifier">new</span>
    <span class="ruby-identifier">album</span>.<span class="ruby-identifier">name</span> = <span class="ruby-value str">&quot;My Album&quot;</span>
    <span class="ruby-identifier">album</span>.<span class="ruby-identifier">person_id</span> = <span class="ruby-identifier">person</span>.<span class="ruby-identifier">person_id</span>
    <span class="ruby-identifier">album</span>.<span class="ruby-identifier">orig_release_date</span> = <span class="ruby-value str">&quot;2008-02-23&quot;</span>
    <span class="ruby-identifier">album</span>.<span class="ruby-identifier">sale_date</span> = <span class="ruby-value str">&quot;2008-02-23&quot;</span>
    <span class="ruby-identifier">album</span>.<span class="ruby-identifier">primary_genre</span> = <span class="ruby-value str">&quot;Rock&quot;</span>
    <span class="ruby-identifier">album</span>.<span class="ruby-identifier">secondary_genre</span> = <span class="ruby-value str">&quot;Alternative&quot;</span>
    <span class="ruby-identifier">album</span>.<span class="ruby-identifier">artist_name</span> = <span class="ruby-value str">&quot;Alex Kane&quot;</span>
    <span class="ruby-identifier">album</span>.<span class="ruby-identifier">label_name</span> = <span class="ruby-value str">&quot;Shochu&quot;</span>
    <span class="ruby-identifier">album</span>.<span class="ruby-identifier">c_copyright</span> = <span class="ruby-value str">&quot;1999&quot;</span>
    <span class="ruby-identifier">album</span>.<span class="ruby-identifier">p_copyright</span> = <span class="ruby-value str">&quot;1999&quot;</span>
    <span class="ruby-identifier">album</span>.<span class="ruby-identifier">recording_location</span> = <span class="ruby-value str">&quot;Brooklyn&quot;</span>
    <span class="ruby-identifier">album</span>.<span class="ruby-identifier">parental_advisory</span> = <span class="ruby-keyword kw">false</span>
    <span class="ruby-identifier">album</span>.<span class="ruby-identifier">stores</span> = <span class="ruby-value str">&quot;iTunesUS,iTunesAU,iTunesCA,iTunesEU,iTunesJP,iTunesEU,RhapsodyRH,MusicNet,Napster,eMusic,Amazon,Lala&quot;</span>
    <span class="ruby-identifier">created</span> = <span class="ruby-identifier">album</span>.<span class="ruby-identifier">create</span>
    <span class="ruby-identifier">assert</span> <span class="ruby-identifier">created</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">true</span>
    
    <span class="ruby-comment cmt">#create the song</span>
    <span class="ruby-identifier">song</span> = <span class="ruby-constant">TunecoreDirect</span><span class="ruby-operator">::</span><span class="ruby-constant">Song</span>.<span class="ruby-identifier">new</span>
    <span class="ruby-identifier">song</span>.<span class="ruby-identifier">album_id</span> = <span class="ruby-identifier">album</span>.<span class="ruby-identifier">album_id</span>
    <span class="ruby-identifier">song</span>.<span class="ruby-identifier">name</span> = <span class="ruby-value str">&quot;My song&quot;</span>
    <span class="ruby-identifier">song</span>.<span class="ruby-identifier">track_num</span> = <span class="ruby-value">1</span>
    <span class="ruby-identifier">song</span>.<span class="ruby-identifier">asset_url</span> = <span class="ruby-value str">&quot;http://s3.amazonaws.com/my_bucket/track_01.mp3&quot;</span>
    <span class="ruby-identifier">assert</span> <span class="ruby-identifier">song</span>.<span class="ruby-identifier">save</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">true</span>
    
    <span class="ruby-comment cmt"># get all albums</span>
    <span class="ruby-identifier">albums</span> = <span class="ruby-constant">TunecoreDirect</span><span class="ruby-operator">::</span><span class="ruby-constant">Album</span>.<span class="ruby-identifier">get_all</span>
    <span class="ruby-identifier">assert</span> <span class="ruby-identifier">albums</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
    
    <span class="ruby-comment cmt"># takedown the first album</span>
    <span class="ruby-identifier">album_id</span> = <span class="ruby-identifier">albums</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">album_id</span>
    <span class="ruby-identifier">assert</span> <span class="ruby-constant">TunecoreDirect</span><span class="ruby-operator">::</span><span class="ruby-constant">Album</span>.<span class="ruby-identifier">takedown</span>( <span class="ruby-identifier">album_id</span> ) <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
    
    <span class="ruby-comment cmt"># get person by email</span>
    <span class="ruby-identifier">person</span> = <span class="ruby-constant">TunecoreDirect</span><span class="ruby-operator">::</span><span class="ruby-constant">Person</span>.<span class="ruby-identifier">get</span>(<span class="ruby-ivar">@email</span>)
    <span class="ruby-identifier">assert</span> <span class="ruby-identifier">person</span>.<span class="ruby-identifier">email</span> = <span class="ruby-ivar">@email</span>
    
    <span class="ruby-comment cmt"># get all the songs for this album</span>
    <span class="ruby-identifier">songs</span> = <span class="ruby-identifier">person</span>.<span class="ruby-identifier">albums</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">songs</span>
    
  <span class="ruby-keyword kw">end</span></pre>
</body>
</html>